package com.talent.controller;

import eu.bitwalker.useragentutils.Browser;
import eu.bitwalker.useragentutils.UserAgent;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 用于测试UserAgentUtil工具Api
 * Created by zhumenglong on 2017/3/31.
 */

@Controller
@RequestMapping("/userAgent")
public class UserAgentTestController {

    @RequestMapping("/myAgent")
    @ResponseBody
    public String returnMyAgent(HttpServletRequest request){
        String userAgent = request.getHeader("user-agent").toLowerCase();
        UserAgent  userAgentObj = UserAgent.parseUserAgentString(userAgent.toString());
        Browser browser = userAgentObj.getBrowser();
        return browser.toString();
    }
}
